function [Env]=PlotDropResutls(data, tZC, strResiduals, g)
global ExperimentParameters;
global ExperimentResults;
global GraphicalObjects;

sampleRate = ExperimentParameters.samplingFrequencies;

axes(GraphicalObjects.zeroCrossingAxes1);
hold off;
if( ~isempty(strResiduals))           
   plot(tZC(1:99:end)*1000, strResiduals(1:99:end)*1e9, 'b.');   % tZC in ms
   set(gca,'yticklabel',strsplit(sprintf('%3.1f|',get(gca,'ytick')),'|'),'FontSize',8);
   %set(gca,'yticklabel',sprintf('%3.1f|',get(gca,'ytick')));
   xlabel('Drop length (ms)');
   ylabel('Residuals (nm)');
   grid on;
   hold on;
end

%%  Plot the envelope of the fringe signal  )
axes(GraphicalObjects.zeroCrossingAxes2);
windowLength = 5e-006;     % length of window to calculate one MIN and one MAX value
                          % minimal value = 3 us to cover at least 3 times  the longest period at 1 MHz fringe signal
nAveraged = 3;             % number points over which one mean value calculated and assigned to window  

samplesInOneWindow = fix(windowLength*sampleRate);
windowsNumber = fix(length(data)/samplesInOneWindow);

portionedChunks = ones(samplesInOneWindow, 1);
minima = ones(windowsNumber , 2);
maxima = ones(windowsNumber , 2);
zeroLevel = ones(windowsNumber , 2);

for i = 1 : windowsNumber            
   envelopeTimeScale = i*windowLength - windowLength/2; % middles of the windows
   maxima(i,1) = envelopeTimeScale;
   minima(i,1) = envelopeTimeScale;
   zeroLevel(i,1) = envelopeTimeScale;
   Env(i,1)= envelopeTimeScale;
   
   startCurrentChunk = samplesInOneWindow *(i-1) + 1; 
   endCurrentChunk = samplesInOneWindow*i;
   portionedChunks(:,1) = data(startCurrentChunk : endCurrentChunk);

   sortedToMax = sort(portionedChunks, 'ascend');

   maxima(i, 2) = mean(sortedToMax(samplesInOneWindow - nAveraged : samplesInOneWindow));
   minima(i, 2) = mean(sortedToMax(1 : nAveraged));
   zeroLevel(i, 2) = (maxima(i, 2) + minima(i, 2))/2;
   
   Env(i,2)= minima(i, 2);
   Env(i,3)= zeroLevel(i, 2);
   Env(i,4)= maxima(i, 2);
end
hold off;
plot(maxima(:,1)*1000, maxima(:,2), 'b'); % time scale converted to ms
hold on;
plot(minima(:,1)*1000, minima(:,2), 'b'); % time scale converted to ms
plot(zeroLevel(:,1)*1000, zeroLevel(:,2), 'k'); % fringes zero level
%set(gca,'yticklabel',sprintf('%3.1f|',get(gca,'ytick')));
set(gca,'yticklabel',strsplit(sprintf('%3.1f|',get(gca,'ytick')),'|'),'FontSize',8);
xlabel('Drop length (ms)');
ylabel('Fringe envelop (V)');
grid on;
hold on;


%% plot gValues in resulttable      
axes (GraphicalObjects.axesResultsGValues);
hold off;

if  ~isempty(g)               
   plot(1:length(g),g - ExperimentResults.SingleDrop.meanGValueOfSet,'--or','LineWidth',1,'MarkerEdgeColor','k','MarkerFaceColor','r', 'MarkerSize',8)
   set(gca,'XTick',0:1:length(g)+1)
end
xlabel('Drop number');
ylabel('Delta g / microgal');
%set(gca,'yticklabel',sprintf('%5.1f|',get(gca,'ytick')));
set(gca,'yticklabel',strsplit(sprintf('%5.1f|',get(gca,'ytick')),'|'),'FontSize',8);
grid on;
hold on;

end